import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';


import { LayoutComponent } from './layout';

import { UserAuthGuard } from './shared/guards';

const routes: Routes = [
  {
    path: '',
    redirectTo: 'dashboard',
    pathMatch: 'full'
  },
  {
    path: '',
    component: LayoutComponent,
    canActivateChild: [ UserAuthGuard ],
    data: {
      name: '首页'
    },
    children: [
      {
        path: 'dashboard',
        loadChildren: './dashboard/dashboard.module#DashboardModule',
        data: {
          name: '仪表盘'
        }
      },
      {
        path: 'map',
        loadChildren: './map/map.module#MapModule',
        data: {
          name: '地图'
        }
      },
      {
        path: 'data',
        loadChildren: './data/data.module#DataModule',
        data: {
          name: '数据中心'
        }
      },
      {
        path: 'personal',
        loadChildren: './personal/personal.module#PersonalModule',
        data: {
          name: '个人中心'
        }
      },
      {
        path: 'accounts',
        loadChildren: './accounts/accounts.module#AccountsModule',
        data: {
          name: '用户管理'
        }
      }
    ]
  },
  {
    path: 'login',
    loadChildren: './pages/login/login.module#LoginModule',
    data: {
      name: '用户登录'
    }
  },
  {
    path: 'register',
    loadChildren: './pages/register/register.module#RegisterModule',
    data: {
      name: '用户注册'
    }
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: true })],
  exports: [RouterModule]
})
export class AppRoutingModule { }
